﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace Z2.Editor
{
	internal class LogListener : TraceListener
	{

		private List<string> m_log;
		private const int LOG_LIMIT = 500;

		public LogListener()
			: base("LogListener")
		{
			this.m_log = new List<string>();
		}

		public string[] Entries
		{
			get { return this.m_log.ToArray(); }
		}

		public override void Write(string message)
		{
			if (this.m_log.Count == 0) this.m_log.Add(string.Empty);
			this.m_log[this.m_log.Count - 1] += message;
		}

		public override void WriteLine(string message)
		{
			this.m_log.Add(DateTime.Now.ToLongTimeString() + ": " + message);
		}

	}
}
